<%--
  Created by IntelliJ IDEA.
  User: wwh
  Date: 2017/8/7
  Time: 10:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>学生个人实习情况</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="../../static/common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../static/common/global.css" media="all">
</head>
<body>
<div style="margin: 15px;" id="Vue" v-cloak>
    <blockquote class="layui-elem-quote" id="start_button">
        <a href="javascript:;" class="layui-btn layui-btn-small" onclick="history.back()">返回</a>
    </blockquote>
    <fieldset class="layui-elem-field">
        <legend><span>{{ user.realname }}</span>的实习情况</legend>
        <div class="layui-form">
            <table class="layui-table">
                <thead>
                <tr>
                    <th>实习单位</th>
                    <th>实习开始时间</th>
                    <th>实习结束时间</th>
                    <th>审核状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="content"></tbody>
            </table>
        </div>
    </fieldset>
    <div class="admin-table-page">
        <div id="paged" class="page">
        </div>
    </div>
</div>
<!--模板-->
<script type="text/html" id="tpl">
    {{# layui.each(d.data, function(index, item){ }}
    <tr>
        <td>{{ item.orgInfo.fullname }}</td>

        {{# var time = getYearMonthDate(item.internInfo.start) }}
        <td>{{ time||"-"}}</td>
        {{#   var time = getYearMonthDate(item.internInfo.end) }}
        <td>{{ time||"-" }}</td>

        {{#  if(item.internInfo.state == 1||item.internInfo.state == 0||item.internInfo.state == ''){ }}
        <td>未提交申请</td>
        {{#  }; }}
        {{#  if(item.internInfo.state == 2){ }}
        <td>待审核</td>
        {{#  }; }}
        {{#  if(item.internInfo.state == 3){ }}
        <td>教师审核通过</td>
        {{#  }; }}
        {{#  if(item.internInfo.state == 4){ }}
        <td>教师审核不通过</td>
        {{#  }; }}
        {{#  if(item.internInfo.state == 5){ }}
        <td>审核通过</td>
        {{#  }; }}
        {{#  if(item.internInfo.state == 6){ }}
        <td>行政审核不通过</td>
        {{#  }; }}
        <td>
            <a href="javascript:;" target="_blank" data-id="{{item.internInfo.id}}" data-opt="details" class="layui-btn layui-btn layui-btn-mini">详情</a>
        </td>
    </tr>
    {{# }); }}
</script>
<!--详情模板-->
<script type="text/html" id="detailTpl">
    {{# var item=d.data }}
    <div class="layui-form-item">
        <label class="layui-form-label">实习单位</label>
        <div class="layui-input-inline">
            <input type="text" name="company" autocomplete="off" class="layui-input" value="{{ item.orgInfo.fullname }}" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实习岗位</label>
        <div class="layui-input-inline">
            <input type="text" name="position" autocomplete="off" class="layui-input" value="{{ item.internInfo.position }}" disabled>
        </div>
        <label class="layui-form-label">岗位介绍</label>
        <div class="layui-input-inline">
            <input type="text" name="jobIntro" autocomplete="off" class="layui-input" value="{{ item.internInfo.jobintro }}" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实习内容</label>
        <div class="layui-input-inline">
            <textarea type="text" name="content" autocomplete="off" class="layui-input" value="{{ item.internInfo.jobcontent }}" disabled>{{ item.internInfo.jobcontent }}</textarea>
        </div>
        <label class="layui-form-label">实习成果</label>
        <div class="layui-input-inline">
            <textarea type="text" name="outcome" autocomplete="off" class="layui-input" value="{{ item.internInfo.outcome }}" disabled>{{ item.internInfo.outcome }}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">开始时间</label>
        <div class="layui-input-inline">
            <input type="text" name="starttime" autocomplete="off" class="layui-input" value="{{ item.internInfo.start }}" disabled>
        </div>
        <label class="layui-form-label">结束时间</label>
        <div class="layui-input-inline">
            <input type="text" name="endtime" autocomplete="off" class="layui-input" value="{{ item.internInfo.end }}" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实习单位指导人员</label>
        <div class="layui-input-inline">
            <input type="text" name="companyGuide" autocomplete="off" class="layui-input" value="{{ item.internInfo.instructor }}" disabled>
        </div>
        <label class="layui-form-label">单位指导联系方式</label>
        <div class="layui-input-inline">
            <input type="text" name="companyGuidePhone" autocomplete="off" class="layui-input" value="{{ item.internInfo.instructorphone }}" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实习办公场地照片</label>
        <div class="layui-input-block">
            <img id="picture" style="height: 100px;width: 100px">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            {{# if(item.internInfo.state == 1){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="未提交申请" disabled>
            {{# }; }}
            {{# if(item.internInfo.state == 2){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="待审核" disabled>
            {{# }; }}
            {{# if(item.internInfo.state == 3){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="教师审核通过" disabled>
            {{# }; }}
            {{# if(item.internInfo.state == 4){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="教师审核不通过" disabled>
            {{# }; }}
            {{# if(item.internInfo.state == 5){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="行政审核通过" disabled>
            {{# }; }}
            {{# if(item.internInfo.state == 6){ }}
            <input type="text" name="state" autocomplete="off" class="layui-input" value="行政审核不通过" disabled>
            {{# }; }}
        </div>
        <label class="layui-form-label">审核意见</label>
        <div class="layui-input-inline">
            <textarea type="text" name="suggestion" autocomplete="off" class="layui-input" value="{{ item.internInfo.auditsug }}" readonly="readonly"></textarea>
        </div>
    </div>
</script>
<script type="text/javascript" src="../../static/common/layui/layui.js"></script>
<script src="../../static/common/axios.min.js"></script>
<script src="../../static/common/vue.min.js"></script>
<script>
    var studentUserId = <%=request.getParameter("studentUserId")%>;
    var user = {};
    var studentInfo = {};
    axios.get('/student/findDetail/'+studentUserId)
        .then(function (response) {
            console.log(response.data);
            user = response.data.data.user;
            studentInfo = response.data.data.studentInfo;
            console.log(vm.user);
        })
        .catch(function (msg) {
            console.log(msg);
        });
</script>
<script>
    /**
     * 时间格式取年月日
     * @param time
     * @returns {*}
     */
    function getYearMonthDate(time) {
        if(time!=null) {
            var YMD = time.split(" ")[0];  // 年月日
            var HMS = time.split(" ")[1];  // 时分秒
            return YMD;
        }
        return null;
    }
    layui.config({
        base: '../../static/js/layuiModulesEX/'
    });
    layui.use(['paging','laytpl','form','laydate','upload'],function () {
        var $ = layui.jquery,
            paging = layui.paging(),
            layerTips = parent.layer === undefined ? layui.layer : parent.layer, //获取父窗口的layer对象
            layer = layui.layer, //获取当前窗口的layer对象
            laytpl = layui.laytpl,
            laydate = layui.laydate,
            image ={},
            form = layui.form();

        var vm = new Vue({
            el:'#Vue',
            data:{
                internInfoDetail:{},
                internInfo:{},
                studentInfo:studentInfo,
                orgInfo:{},
                user:user
            },
            methods:{}
        });

        paging.init({
            url: '/internInfo/findByCondition', //地址
            elem: '#content', //内容容器
            params: { //发送到服务端的参数
                sno:studentInfo.id,
                isTemporary:1
            },
            contentType : "application/json; charset=utf-8",
            type: 'POST',
            tempElem: '#tpl', //模块容器
            pageConfig: { //分页参数配置
                elem: 'paged', //分页容器
                pageSize:10 //分页大小
            },
            success:function () {
//                alert('渲染成功');
            },
            fail: function(msg) { //获取数据失败的回调
                alert('获取数据失败')
            },
            complate:function () {
//                alert("回调成功");
                $('#content').children('tr').each(function () {
                    //获取每行记录id值
                    var $that = $(this).children('td:last-child');
                    var id = $that.children('a[data-opt=details]').data('id');
                    console.log(id);
                    /**
                     * 详情按钮
                     */
                    $that.children('a[data-opt=details]').on('click', function () {
                        axios.get('/internInfo/findOne/' + id)
                            .then(function (response) {
//                                console.log(response.data);
                                vm.internInfoDetail = response.data;
                                layer.open({
                                    type: 1,
                                    title: "实习信息",
                                    content: laytpl($('#detailTpl').html()).render(vm.internInfoDetail),
                                    shade: [0.5, '#FFF'], //模态框
                                    area: ['700px', '600px'],
                                    zIndex: 19950924,
                                    btn: ['返回'],
                                    yes: function (index) {
                                        layer.close(index);
                                    }
                                });
                                //改变图片显示 Todo 营业执照显示问题
                                if (response.data.data.image !== null) {
                                    console.log(response.data.data.image);
                                    $('#picture').attr('src', response.data.data.image.path);
                                }
                            })
                            .catch(function (msg) {
                                console.log(msg);
                            })
                    })
                });
            }
        });
    });
</script>
</body>
</html>
